/**
 * Copyright 2016-2018 mobaas.com
 */
package com.mobaas.devops;

/**
 * 
 * @author billy zhang
 * 
 */
public class JsonResult<T> {

	private int errCode;
	private String errMsg = "";
	private T data;
	
	public int getErrCode() {
		return errCode;
	}
	public void setErrCode(int errCode) {
		this.errCode = errCode;
	}
	public String getErrMsg() {
		return errMsg;
	}
	public void setErrMsg(String errMsg) {
		this.errMsg = errMsg;
	}
	public T getData() {
		return data;
	}
	public void setData(T data) {
		this.data = data;
	}
	 
	public static <T> JsonResult<T> ok(T result) {
		JsonResult<T> jsonRet = new JsonResult<>();
		jsonRet.setData(result);
		return jsonRet;
    }

	public static <T> JsonResult<T> fail(int errCode, String errMsg) {
		JsonResult<T> jsonRet = new JsonResult<>();
		jsonRet.setErrCode(errCode);
		jsonRet.setErrMsg(errMsg);
		return jsonRet;
	}
	
	private JsonResult() {

	}

}
